package client.comm.baoding.adapter

import android.content.Context
import androidx.recyclerview.widget.DiffUtil
import client.comm.commlib.base.BasePagingAdapter
import client.comm.commlib.base.PagingViewHoder
import client.comm.baoding.R
import client.comm.baoding.api.bean.Zcjl
import client.comm.baoding.databinding.LayoutDaysignitemBinding

class DaySignAdapter(val context: Context) :
    BasePagingAdapter<Zcjl.Record>(object : DiffUtil.ItemCallback<Zcjl.Record>() {
        override fun areItemsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return oldItem.create_time == newItem.create_time
        }

        override fun areContentsTheSame(
            oldItem: Zcjl.Record,
            newItem: Zcjl.Record
        ): Boolean {
            return oldItem == newItem
        }
    }) {

    override fun getItemLayout(): Int {
        return R.layout.layout_daysignitem
    }

    override fun bindItem(holder: PagingViewHoder, t: Any) {
        val binding = holder.binding as LayoutDaysignitemBinding
        val bean = t as Zcjl.Record
        binding.bean = bean

        when (bean.r_state) {
            1 -> {
                binding.num = "+${bean.num}"
            }
            2 -> {
                binding.num = "-${bean.num}"
            }
        }
    }


}